package com.example.its2021606134chh.BusModule;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.its2021606134chh.R;
import com.example.its2021606134chh.TLModule.Lights;
import com.example.its2021606134chh.TLModule.TLightsRViewAdapter;

import java.util.List;

/**
 * @ClassName: BusRViewAdapter$
 * @Description: 作用
 * @Author: letquit
 * @CreateDate: 19/8/2021$
 * @Version: 1.0
 */
public class BusRViewAdapter extends RecyclerView.Adapter<BusRViewAdapter.ViewHolder> {
    List<rvBusData> list;
    public BusRViewAdapter(List<rvBusData> list) {
        this.list = list;
    }
    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_bus,  parent, false);
        return new BusRViewAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        rvBusData busLists = list.get(position);
        holder.tvItemListID.setText(String.valueOf(position + 1));
        holder.tvItemBusId.setText(String.valueOf(busLists.getBusId()));
        holder.tvItemBusCapacity.setText(String.valueOf(busLists.getCapacity()));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvItemListID, tvItemBusId, tvItemBusCapacity;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvItemListID = itemView.findViewById(R.id.tvItemListID);
            tvItemBusId = itemView.findViewById(R.id.tvItemBusId);
            tvItemBusCapacity = itemView.findViewById(R.id.tvItemBusCapacity);
        }
    }
}
